import React from "react";
import { useCallback, useState } from "react";

export default function useToggle(
  initialValue: boolean = false
): [boolean, () => void] {
  const [state, setState] = useState(initialValue);
  const toggle = useCallback(() => {
    setState((state) => !state);
  }, []);
  return [state, toggle];
}